//
//  GRGoodDetailTipView.m
//  YC_GRice
//
//  Created by luojinrong11 on 2018/9/12.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GRGoodDetailTipView.h"
#import "GRGooDetailTipCell.h"
@implementation GRGoodDetailTipView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(void)show{
    UIWindow * window = [UIApplication sharedApplication].keyWindow;
    [window addSubview:self];
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(window);
    }];
}

-(void)awakeFromNib{
    [super awakeFromNib];
    self.dataArr = @[ @{@"title":@"随时退",@"content":@"购买未使用，可随时申请退款"},@{@"title":@"过期退",@"content":@"优惠套餐，购买后未使用且已过有效期，将自动退款"}
                      ];
    self.listView.delegate = self;
    self.listView.dataSource = self;
    [self.listView registerNib:[UINib nibWithNibName:@"GRGooDetailTipCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"GRGooDetailTipCell"];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    GRGooDetailTipCell * cell = [tableView dequeueReusableCellWithIdentifier:@"GRGooDetailTipCell" forIndexPath:indexPath];
    NSDictionary * dic = self.dataArr[indexPath.row];
    cell.titleLabel.text = dic[@"title"];
    cell.contentLabel.text = dic[@"content"];
    return cell;
    
}



-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArr.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}

- (IBAction)closeAction:(id)sender {
    [self removeFromSuperview];
}

@end
